﻿using SHKF.B2C.Model.Dto;
using SHKF.B2C.YouZanYun.Model.Inter.Center;
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes; 
namespace SHKF.B2C.Mannage.AdminUI.View.CenterInfo.Product
{
    /// <summary>
    /// frmSearchProductYZY.xaml 的交互逻辑
    /// </summary>
    public partial class frmSearchProductYZY : Window
    {
        public long CompanySN = 0;
        private string authority_id = "";
        public frmSearchProductYZY()
        {
            InitializeComponent();
        }

        
  
        private void btnSearchProduct_Click(object sender, RoutedEventArgs e)
        {
            LoadData();
        }

        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //加载总部Id
           DataDto dto = await GL.HttpClientManage.ShopGetKdtId(CompanySN);
            if (dto.error == null)
            {
                authority_id = dto.data;

                if (this.authority_id != "")
                {
                    LoadData();
                }
            }
        }

        private async void LoadData()
        { 
            ItemsDto dto = await GL.HttpClientYzy.GetOnSaleProduct(this.authority_id, this.txtProduct.Text);
            this.dgvProduct.ItemsSource = dto.data.items;
        }

        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (this.dgvProduct.SelectedItem != null)
            {
                SelectData = (PrductItem)this.dgvProduct.SelectedItem;
                this.DialogResult = true;
                this.Close();
            } 
        }

        public PrductItem SelectData;

    }
}
